
** DRUGS AND ALCOHOL **


	// Fixing missings and others

		foreach x of varlist  drugsell2wx_e stealtakethingsx_e stealscrapex_e fightsmlneigh_e fightbigneigh_e fightsmlleader_e fightbigleader_e fightsmlpolice_e fightbigpolice_e {
			replace `x'=.n if `x'==-999
		}


	// HARMONIZING ACROSS SURVEY

		// P1 Baseline only we asked what do you smoke cigarette or marijuana. In subsequent version we asked do you smoke grass? We populate the latter one.
			* In p1 thre is an incorrect skip from the previous question which is "Do your friend smoke?" If they said no, they skipped the drug grass self question.

			replace druggrassself_b = 1 if (druggrassselfmarijuana_b==2 |druggrassselfmarijuana_b==3) & p1==1
			replace druggrassself_b = 0 if druggrassselfmarijuana_b==1  & p1==1
			replace druggrassself_b = .d if druggrassselfmarijuana_b == .d

			* In p1 we asked about days and not time

			replace drinkbooze7d_b = drinkbooze7ddys_b if p1==1

			* Issue with p1_baseline wrong skip pattern for grassever
			replace druggrassself_b = 0 if druggrassself_b==. & p1 ==1
			replace drugntgrss7d_e  = 0 if drugntgrss7d_e ==. & p1 ==1
			replace druggrass7d_b = 0 if druggrass7d_b==. & p1 ==1
			replace drugntgrss7d_b = 0 if drugntgrss7d_b ==. & p1==1

		// P2 Baseline. We asked about gin and beer separately while in other survey we ask about alcohol in general. We populate the alochol variables here.

			replace drinkboozeself_b = 1 if (drinkbeerwineself_b==1 | drinkginself_b==1) & p2==1
			replace drinkboozeself_b = 0 if (drinkbeerwineself_b==0 & drinkginself_b==0) & p2==1

			egen temp = rowmax(drinkbeerwine7ddys_b  drinkgin7ddys_b)
			replace drinkbooze7ddys_b = temp if  p2==1
			drop temp

			replace drinkbooze7d_b= drinkbooze7ddys_b if p2==1

		// P1 3wks Endline we asked tablet and hard drugs separately, we combine them here.

			replace drugntgrssself_e = 1 if (drugtablet_e ==1 | drughard_e ==1) & p1_e3wks==1
			replace drugntgrssself_e = 0 if (drugtablet_e ==0 & drughard_e ==0) & p1_e3wks==1

			egen temp = rowmax (drugtablet4wx_e drughard4wx_e)
			gen drugntgrss4wx_e =temp if p1_e3wks==1
			drop temp

		// In p1_3wks and p2_b we asked about the last 4 weeks not the last 7 days.

			replace drugntgrss7d_e = drugntgrss4wx_e/4 if p1_e3wks==1
			replace drugntgrss7d_b = drugntgrss4wx_b/4 if p2==1

		// P1 3wks Endline we asked how many days did you drink and not how many drinks

			replace drinkbooze7d_e = drinkbooze7ddys_e if p1_e3wks==1

		// IN ALL SURVEY, WE REPLACE MISSING BY ZERO WHEN IT IS THE RESULT OF A SKIP

			replace drinkbooze7d_e = 0 if drinkboozeself_e== 0 & drinkbooze7d_e==. & p1_e3wks==1
			replace druggrass7d_e = 0 if druggrassself_e== 0 & druggrass7d_e==. & p1_e3wks==1
			replace drugntgrss7d_e = 0 if drugntgrssself_e== 0 & drugntgrss7d_e==. & (p1_e5m==1 | p1_e12m ==1 | p2_e2wks==1 |p1_e7m==1 |p1_e13m==1 | p2_e12m==1 | p2_e13m==1 | p3_e12m==1 | p3_e13m==1 | p1_e9y==1 | p2_e9y==1 | p3_e9y==1 | p1_e10y==1 | p2_e10y==1 | p3_e10y==1)
			replace drugntgrss7d_e = 0 if drugntgrssself_e== 0 & drugntgrss7d_e==. & (p2_e2w2w==1 | p3_e2w==1 | p3_e5w==1)
			replace drugntgrssprev7d_e = 0 if drugntgrssself_e == 0 & drugntgrssprev7d_e==. & (p1_e5m ==1 | p1_e7m ==1 | p1_e12m ==1 | p1_e13m==1 |p2_e2wks==1 | p2_e2w2w==1| p3_e2w==1 | p3_e5w==1 | p2_e12m==1 | p2_e13m==1 | p3_e12m==1 | p3_e13m==1 | p1_e9y==1 | p2_e9y==1 | p3_e9y==1 | p1_e10y==1 | p2_e10y==1 | p3_e10y==1)

			replace drinkbooze7d_b = 0 if drinkboozeself_b == 0 & drinkbooze7d_b==. & p1==1
			replace drinkbooze7d_b = 0 if drinkboozeself_b == 0 & drinkbooze7d_b==. & p2==1
			replace druggrass7d_b = 0 if druggrassself_b == 0 & druggrass7d_b==. & p2==1
			replace drugntgrss7d_b = 0 if drugntgrssself_b == 0 & drugntgrss7d_b==. & p2==1
			replace drugntgrss7d_b = 0 if drugntgrssself_b == 0 & drugntgrss7d_b==. & p3==1
			replace drugntgrssprev7d_b = 0 if drugntgrssself_b == 0 & drugntgrssprev7d_b==. & p3==1


		foreach p in b e {

		// ALCOHOL
			gen drinkboozeever_`p' = drinkboozeself_`p'
				la var drinkboozeever_`p' "Indicator for usually drinks"

			gen drinkboozedailyuser_`p' = (drinkbooze7d_`p'>6) if drinkbooze7d_`p'!=.
				la var drinkboozedailyuser_`p' "Indicator for drinks booze daily"

		// GRASS AND HARD DRUGS CONSUMPTION

			gen grassever_`p' = 	druggrassself_`p'
				la var grassever_`p' "Indicator for usually smokes grass"

			gen grassdailyuser_`p' = 	(druggrass7d_`p'>6) if druggrass7d_`p'!=.
				la var grassdailyuser_`p' "Indicator for smokes Grass Daily"

			gen harddrugsever_`p' = drugntgrssself_`p'
				la var harddrugsever_`p' "Indicator for usually Takes hard drugs"

			gen harddrugsdailyuser_`p' = (drugntgrss7d_`p'>6) if drugntgrss7d_`p'!=.
				la var harddrugsdailyuser_`p' "Indicator for take hard drugs daily"

			gen druguser_`p'=0 if  (grassever_`p'!=. | harddrugsever_`p'!=.)
			replace druguser_`p'=1 if (grassever_`p'==1 | harddrugsever_`p'==1)
				la var druguser_`p' "Indicator for usually smokes grass or takes hard drugs"

		// SUBSTANCE ABUSE

			egen subabuse_`p' = rowtotal(drinkboozeever_`p' grassever_`p' harddrugsever_`p'),m
				la var subabuse_`p' "Substance abuse"

				summ subabuse_`p'
				replace subabuse_`p' = ((subabuse_`p' - r(mean))/ r(sd))



		}

		// AVERAGE 7D and LAST 7D

			egen druggrassavg7d_e = rowmean (druggrass7d_e druggrassprev7d_e) if p1_e5m ==1 | p1_e7m ==1 | p1_e12m ==1 | p1_e13m ==1 | p2_e2wks ==1 | p2_e2w2w==1 | p3_e2w==1 | p3_e5w==1 | p2_e12m==1 | p2_e13m==1 | p3_e12m==1 | p3_e13m==1 | p1_e9y==1 | p2_e9y==1 | p3_e9y==1 | p1_e10y==1 | p2_e10y==1 | p3_e10y==1
				la var druggrassavg7d_e "Drugs: Grass Time 7d Avg"

		 	egen drinkboozeavg7d_e = rowmean (drinkbooze7d_e drinkboozeprev7d_e) if p1_e5m ==1 | p1_e7m ==1 | p1_e12m ==1 | p1_e13m ==1 | p2_e2wks ==1 | p2_e2w2w==1 | p3_e2w==1 | p3_e5w==1 | p2_e12m==1 | p2_e13m==1 | p3_e12m==1 | p3_e13m==1 | p1_e9y==1 | p2_e9y==1 | p3_e9y==1 | p1_e10y==1 | p2_e10y==1 | p3_e10y==1
				la var drinkboozeavg7d_e "Drugs: Alcohol Time 7d Avg"

			egen drugntgrssavg7d_e = rowmean (drugntgrss7d_e drugntgrssprev7d_e) if p1_e5m ==1 | p1_e7m ==1 | p1_e12m ==1 | p1_e13m ==1 | p2_e2wks ==1 | p2_e2w2w==1 | p3_e2w==1 | p3_e5w==1 | p2_e12m==1 | p2_e13m==1 | p3_e12m==1 | p3_e13m==1 | p1_e9y==1 | p2_e9y==1 | p3_e9y==1 | p1_e10y==1 | p2_e10y==1 | p3_e10y==1
				la var drugntgrssavg7d_e "Drugs: Drugs not Grass Time 7d Avg"

	// ADDICTION

	foreach x in b e {
		gen drinkboozeaddict_`x' = (drinkboozedailyuser_`x' == 1 & drinkboozeevday_`x' == 1) if (!missing(drinkboozedailyuser_`x')&!missing(drinkboozeevday_`x'))
			replace drinkboozeaddict_`x' = 0 if drinkboozeaddict_`x'==. & drinkboozeever_`x' ==0
			la var drinkboozeaddict_`x' "Addicted to alcohol"

		gen druggrassaddict_`x' = (grassdailyuser_`x' == 1 & druggrassevday_`x' == 1) if (!missing(grassdailyuser_`x')&!missing(druggrassevday_`x'))
			replace druggrassaddict_`x' = 0 if druggrassaddict_`x'==. & grassever_`x' ==0
			la var druggrassaddict_`x' "Addicted to grass"

		gen drugntgrssaddict_`x' = (harddrugsdailyuser_`x' == 1 & drugntgrssevday_`x' == 1) if (!missing(harddrugsdailyuser_`x')&!missing(drugntgrssevday_`x'))
			replace drugntgrssaddict_`x' = 0 if drugntgrssaddict_`x'==. & harddrugsever_`x' ==0
			la var drugntgrssaddict_`x' "Addicted to hard drugs"
	}
